import reques from '@/plugins/request'
export function categoryList (params) {
  return reques({
    url: 'categories',
    method: 'get',
    params
  })
}
export function addCategory (data) {
  return reques({
    url: 'categories',
    method: 'post',
    data
  })
}
export function deleteCategory (id) {
  return reques({
    url: `categories/${id}`,
    method: 'delete'
  })
}
export function editCategory (params) {
  return reques({
    url: `categories/${params.cat_id}`,
    method: 'put',
    data: {
      cat_name: params.cat_name
    }
  })
}
// 获取tab列表数据
export function manyParams (data) {
  return reques({
    url: `categories/${data.id}/attributes`,
    method: 'get',
    params: {
      sel: data.sel
    }
  })
}
export function addAttr (params) {
  return reques({
    url: `categories/${params.id}/attributes`,
    method: 'post',
    data: {
      ...params.data
    }
  })
}
export function editAttr (params) {
  return reques({
    url: `categories/${params.catId}/attributes/${params.attr_id}`,
    method: 'put',
    data: {
      ...params.data
    }
  })
}
export function deleteAttr (params) {
  return reques({
    url: `categories/${params.catId}/attributes/${params.attr_id}`,
    method: 'delete'
  })
}
// addAttrVals
export function addAttrVals (params) {
  return reques({
    url: `categories/${params.catId}/attributes/${params.attr_id}`,
    method: 'put',
    data: {
      ...params.data
    }
  })
}
